package com.huawei.admins.platform.gateway.core.component.predicate;

import org.reactivestreams.Publisher;
import reactor.core.publisher.Mono;

import java.util.function.Predicate;

public class DefaultAsyncPredicate<T> implements AsyncPredicate<T> {

    private final Predicate<T> delegate;

    public DefaultAsyncPredicate(Predicate<T> delegate) {
        this.delegate = delegate;
    }

    @Override
    public Publisher<Boolean> apply(T t) {
        return Mono.just(delegate.test(t));
    }

    @Override
    public String toString() {
        return this.delegate.toString();
    }
}
